package com.mes.check.service;


import java.util.Collection;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.bstek.dorado.annotation.DataProvider;
import com.bstek.dorado.annotation.DataResolver;
import com.mes.check.dao.iface.ICheckBillDetailDao;
import com.mes.check.domain.CheckBill;
import com.mes.check.domain.CheckBillDetail;
import com.mes.common.service.BasicService;

@Service
public class CheckBillDetailService extends BasicService<CheckBillDetail> {

	@Autowired
	ICheckBillDetailDao checkBillDetailDao;
	@Autowired
	CheckBillService checkBillService;
	
	/**
	 * 获取某个检验要求的图示html
	 * @param checkTaskUid
	 * @return
	 * @throws Exception
	 */
	@DataProvider
	public String getCheckPic(String checkBillDetailUid) throws Exception {
		return checkBillDetailDao.getCheckPicHtml(checkBillDetailUid);
	}
	
	@DataResolver
	public void saveAllData(Map<String, Collection<CheckBill>> dataItems) throws Exception {
		Collection<CheckBill> checkBills = dataItems.get("dsCheckBill");
		for(CheckBill bill : checkBills){
			Collection<CheckBillDetail> details = bill.getCheckBillDetails();
			this.saveAll(details);
		}
		checkBillService.saveAll(checkBills);
	}
}
